﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ManageForm
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
            this.WindowState = FormWindowState.Maximized;
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {

            ProgramForm billListForm = new ProgramForm();
            var form = this.MdiChildren.FirstOrDefault(t => t.Name == billListForm.Name);
            if (form == null)
            {
                billListForm.MdiParent = this;
                billListForm.Show();
                billListForm.Dock = DockStyle.Fill;
            }
            else {
                if (form.WindowState == FormWindowState.Minimized) form.WindowState = FormWindowState.Normal;
                form.BringToFront();
            }
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
            ProgramForm billListForm = new ProgramForm();
            billListForm.MdiParent = this;
            billListForm.Show();
            billListForm.Dock = DockStyle.Fill;
        }

        private void getChildForms() {
            
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            ChannelListForm form = new ChannelListForm();
            form.ShowDialog();
        }

        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            ResetPasswordForm form = new ResetPasswordForm();
            form.ShowDialog();
        }

        private void 节目单列表_Click(object sender, EventArgs e)
        {
            ProgramForm billListForm = new ProgramForm();
            var form = this.MdiChildren.FirstOrDefault(t => t.Name == billListForm.Name);
            if (form == null)
            {
                billListForm.MdiParent = this;
                billListForm.Show();
                billListForm.Dock = DockStyle.Fill;
            }
            else
            {
                if (form.WindowState == FormWindowState.Minimized) form.WindowState = FormWindowState.Normal;
                form.BringToFront();
            }
        }

        private void toolStripBillMonitorSetting_Click(object sender, EventArgs e)
        {
            ProgramMonitorSettingForm form = new ProgramMonitorSettingForm();
            form.ShowDialog();
        }

        private void toolStripButton5_Click(object sender, EventArgs e)
        {
            PlayMonitor monitorForm = new PlayMonitor();
            var form = this.MdiChildren.FirstOrDefault(t => t.Name == monitorForm.Name);
            if (form == null)
            {
                monitorForm.MdiParent = this;
                monitorForm.Show();
                monitorForm.Dock = DockStyle.Fill;
            }
            else
            {
                if (form.WindowState == FormWindowState.Minimized) form.WindowState = FormWindowState.Normal;
                form.BringToFront();
            }
        }
    }
}
